package com.moon.robot.mapper;


import com.forte.qqrobot.anno.depend.Beans;

import com.moon.robot.pojo.KeyCode;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper
@Beans
public interface KeyMapper {
    @Select("SELECT keycode FROM keycode where del=1 and keycode=#{key}")
    List<String> selKey(String key);

    @Insert("INSERT INTO keycode(keycode,addqq,creatTime) VALUES(#{KeyCode.keycode},#{KeyCode.addqq},#{KeyCode.creatTime})")
    Integer addKey(@Param("KeyCode") KeyCode keyCode);


    @Update("UPDATE keycode SET del = 0,useTime=NOW() WHERE keycode=#{key}")
    Integer delKey(String key);

    @Update("UPDATE keycode SET del = 0  WHERE ROUND((NOW()-creatTime)/60)>5")
    Integer delAllKey();



    @Select("SELECT num FROM keynum")
    Integer selnum();

    @Update("UPDATE keynum SET num = #{num}")
    Integer reducenum(Integer num);

    @Insert("INSERT INTO keyqq(qq) VALUES(#{qq})")
    Integer addKeyQQ(String qq);

    @Delete("TRUNCATE TABLE keyqq")
    Integer deletekeyqq();

    @Select("SELECT qq FROM keyqq where qq=#{qq}")
    String selKeyqq(String qq);
}
